﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_Modes;
using Zor_IDAL;
using Zor_Tools;

namespace Zor_DAL
{
   public class Zor_InputJinSan_DAL<T>  where T : class
    {
        /// <summary>
        /// 金三录入-新增
        /// </summary>
        /// <param name="jinsan">修改金三录入表并且修改缴税统计表</param>
        /// <returns>执行结果：1 成功 0失败</returns>
       public static BaseAnswer UpdateJInSan(dynamic jinsan)
        {
         
            var sql = "";          
            jinsan.User_Id = RequestSession.GetSessionUser().User_Id;
            jinsan.Js_CreateDate = TimeHelper.ToNowTimeStamp();
            jinsan.Js_State = 2;
            //字轨
            if (jinsan.Js_Zigui1 != null && jinsan.Js_Zigui2 == null && jinsan.Js_Zigui3 == null)
            {
                jinsan.Js_Zigui = jinsan.Js_Zigui + "-" + jinsan.Js_Zigui1;
            }
            if (jinsan.Js_Zigui1 != null && jinsan.Js_Zigui2 != null && jinsan.Js_Zigui3 == null)
            {
                jinsan.Js_Zigui = jinsan.Js_Zigui + "-" + jinsan.Js_Zigui1 + "-" + jinsan.Js_Zigui2;
            }
            if (jinsan.Js_Zigui1 != null && jinsan.Js_Zigui2 != null && jinsan.Js_Zigui3 != null)
            {
                jinsan.Js_Zigui = jinsan.Js_Zigui + "-" + jinsan.Js_Zigui1 + "-" + jinsan.Js_Zigui2 + "-" + jinsan.Js_Zigui3;
            }
            else
            {
                jinsan.Js_Zigui = jinsan.Js_Zigui ;
            }
            
            //发票
            if (jinsan.Js_Dinvoice1 != null && jinsan.Js_Dinvoice2 == null && jinsan.Js_Dinvoice3 == null)
            {
                jinsan.Js_Dinvoice = jinsan.Js_Dinvoice + "-" + jinsan.Js_Dinvoice1;
            }
            if (jinsan.Js_Dinvoice1 != null && jinsan.Js_Dinvoice2 != null && jinsan.Js_Dinvoice3 == null)
            {
                jinsan.Js_Dinvoice = jinsan.Js_Dinvoice + "-" + jinsan.Js_Dinvoice1 + "-" + jinsan.Js_Dinvoice2;
            }
            if (jinsan.Js_Dinvoice1 != null && jinsan.Js_Dinvoice2 != null && jinsan.Js_Dinvoice3 !=null)
            {
                jinsan.Js_Dinvoice = jinsan.Js_Dinvoice + "-" + jinsan.Js_Dinvoice1 + "-" + jinsan.Js_Dinvoice2 + "-" + jinsan.Js_Dinvoice3;
            }
            else
            {
                jinsan.Js_Dinvoice = jinsan.Js_Dinvoice;
            }
            //修改金三录入表
            sql += "update [Zor_Jinsan] set Js_Increment=@Js_Increment*100, Js_HouseTax=@Js_HouseTax*100,Js_UrbanTax=@Js_UrbanTax*100,Js_Education=@Js_Education*100,Js_LocalEducation=@Js_LocalEducation*100,Js_Stamp=@Js_Stamp*100,Js_PersonTax=@Js_PersonTax*100,Js_WaterTax=@Js_WaterTax*100,Js_Zigui=@Js_Zigui,Js_Dinvoice=@Js_Dinvoice,Js_Tax=@Js_Tax*100,User_Id=@User_Id,Js_CreateDate=@Js_CreateDate,Js_State=@Js_State,Js_CertificateNumber=@Js_CertificateNumber  where Js_Id = @Js_Id";            
            BaseAnswer bar = DapperEdit<T>.DoEdit(sql, jinsan);
            return bar;
        }
    }
}
